count occurrences of an element in a list